package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author 啊滨
 * @date 2023/2/14 9:49
 */
@Mapper
public interface UserMapper {
    /**
     * 根据用户编号与密码查询用户信息
     * @param userId
     * @param password
     * @return
     */
    @Select("SELECT * FROM user WHERE userId=#{userId} AND password=#{password}")
    public User getUserByIdByPass(String userId, String password);

    /**
     *  根据用户编号查询用户表返回的行数
     * @param userId
     * @return
     * @throws Exception
     */
    @Select("SELECT COUNT(*) FROM user WHERE userId=#{userId}")
    public int getUserById(String userId);

    /**
     * 添加用户
     * @param userId
     * @param password
     * @param userName
     * @param userSex
     * @return
     * @throws Exception
     */
    @Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1)")
    public int saveUser(String userId,String password,String userName,Integer userSex);
}
